/*
 * MainResult.java
 *
 * Created on February 21, 2007, 4:53 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package ge.info.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
public class MainResult implements java.io.Serializable
{

    /**
     * Creates a new instance of MainResult
     */
    private int mainID;
    private int masterID;
    private Address address;
    private List<MainResultDetail> details;

    public MainResult()
    {
    }

    public int getMainID()
    {
        return mainID;
    }

    public void setMainID(int mainID)
    {
        this.mainID = mainID;
    }

    public String getMainName()
    {
        StringBuffer sb = new StringBuffer();
        for (MainResultDetail mainResultDetail : getDetails())
        {
            if (mainResultDetail.getVisibleOption() < 1001)
            {
                sb.append(mainResultDetail.getMainDetail()).append("           ");
            }
            else
            {
                break;
            }
        }
        return sb.toString();
    }
        
    public List<MainResultDetail> getDetails()
    {
//        if (details == null)
//        {
//            details = new ArrayList<MainResultDetail>();
//        }
        return details;
    }

    public void setDetails(List<MainResultDetail> details)
    {
        this.details = details;
    }

    public int getMasterID()
    {
        return masterID;
    }

    public void setMasterID(int masterID)
    {
        this.masterID = masterID;
    }

    public Address getAddress()
    {
        if (address == null)
        {
            address = new Address();
        }
        return address;
    }

    public void setAddress(Address address)
    {
        this.address = address;
    }
    
    
    
    
    public MainResultDetail getFirstDetail()
    {
        if (details == null)
        {
            return null;
        }
        return details.get(0);
    }    
    public List<MainResultDetail> getOtherDetails()
    {
        if (details == null)
        {
            return null;
        }        
        List<MainResultDetail> dets = new  ArrayList<MainResultDetail>();
        int i = 0;
        for (MainResultDetail det: details)
        {
            if (i>0)
            {
                dets.add(det);
            }
            i++;
        }        
        return dets;
    }    
//    public List<MainResultDetail> getDeptsDetails()
//    {
//        if (details == null)
//        {
//            return null;
//        }
//        List<MainResultDetail> dets = new  ArrayList<MainResultDetail>();
//
//        for (MainResultDetail det: details)
//        {
//            if (det.getDetailTypeID()==30 || det.getDetailTypeID()==5)
//            {
//                dets.add(det);
//            }
//        }
//        return dets;
//    }
//    public List<MainResultDetail> getNoDeptsDetails()
//    {
//        if (details == null)
//        {
//            return null;
//        }
//        List<MainResultDetail> dets = new  ArrayList<MainResultDetail>();
//
//        for (MainResultDetail det: details)
//        {
//            if (det.getDetailTypeID()!=30 && det.getDetailTypeID()!=5)
//            {
//                dets.add(det);
//            }
//        }
//        return dets;
//    }
//    public String getWorkingHours()
//    {
//        String result = null;
//        for (MainResultDetail detail : getDetails())
//        {
//            if (detail.getDetailTypeID() == 8)
//            {
//                result = detail.getMainDetail();
//                break;
//            }
//        }
//        return result;
//    }
//
//    public String getComment()
//    {
//        String result = null;
//        for (MainResultDetail detail : getDetails())
//        {
//            if (detail.getDetailTypeID() == 6)
//            {
//                result = detail.getMainDetail();
//                break;
//            }
//        }
//        return result;
//    }
//
//    public String getDirector()
//    {
//        String result = null;
//        for (MainResultDetail detail : getDetails())
//        {
//            if (detail.getDetailTypeID() == 11)
//            {
//                result = detail.getMainDetail();
//                break;
//            }
//        }
//        return result;
//    }

}
